﻿using DataModels.Dto;
using DataModels.Dto.Community;
using DataModels.Entities.Community;
using Microsoft.AspNetCore.Mvc;
using Services.Community;
using Utils;

namespace PropertyManagementWebApi.Controllers.Community
{
    public class PropertyAnnouncementController(PropertyAnnouncementService propertyAnnouncementService) : BaseController
    {
        protected readonly PropertyAnnouncementService _propertyAnnouncementService = propertyAnnouncementService;

        /// <summary>
        /// 获取物业公告列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetPropertyAnnouncement([FromQuery] GetPropertyAnnouncementiInfo info, string? search = null)
        {
            return _propertyAnnouncementService.GetPropertyAnnouncement(info,null,search);
        }

        /// <summary>
        /// 获取物业公告详情
        /// </summary>
        /// <param name="PropertyAnnouncementUUID"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetPropertyAnnouncementDetail([FromQuery][GeneralRequired] Guid PropertyAnnouncementUUID)
        {
            return _propertyAnnouncementService.GetPropertyAnnouncement(new GetPropertyAnnouncementiInfo { }, PropertyAnnouncementUUID);
        }

        /// <summary>
        /// 物业公告评论
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel CreatePropertyAnnouncementComments(CreatePropertyAnnouncementCommentsInfo info)
        {
            return _propertyAnnouncementService.CreatePropertyAnnouncementComments(info);
        }

        /// <summary>
        /// 获取物业公告评论列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetPropertyAnnouncementComments([FromQuery] PropertyAnnouncementRequest info)
        {
            return _propertyAnnouncementService.GetPropertyAnnouncementComments(info);
        }

        /// <summary>
        /// 点赞物业公告
        /// </summary>
        /// <param name="PropertyAnnouncementUUID"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel LikePropertyAnnouncement([GeneralRequired] Guid PropertyAnnouncementUUID)
        {
            return _propertyAnnouncementService.LikePropertyAnnouncement(PropertyAnnouncementUUID);
        }

        /// <summary>
        /// 取消点赞物业公告
        /// </summary>
        /// <param name="PropertyAnnouncementUUID"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel UnLikePropertyAnnouncement([GeneralRequired] Guid PropertyAnnouncementUUID)
        {
            return _propertyAnnouncementService.UnLikePropertyAnnouncement(PropertyAnnouncementUUID);
        }

        /// <summary>
        /// 订阅物业公告
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel SubscribeToPropertyAnnouncement()
        {
            return _propertyAnnouncementService.SubscribeToPropertyAnnouncement();
        }

        /// <summary>
        /// 取消订阅物业公告
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel UnsubscribePropertyAnnouncement()
        {
            return _propertyAnnouncementService.UnsubscribePropertyAnnouncement();
        }

        /// <summary>
        /// 删除物业公告评论，只能删除自己的，如遇有子级评论一并删除。 add by tianjh 20250806
        /// </summary>
        /// <param name="UUID"></param>
        /// <returns></returns> 
        [HttpGet]
        public ResponseModel DelPropertyAnnouncementComments(Guid UUID)
        {
            return _propertyAnnouncementService.DelPropertyAnnouncementComments(UUID);
        }


    }
}
